package com.lzx.adx.report.support.strategy.mpping;

import com.alibaba.fastjson.JSONObject;
import com.lzx.adx.report.model.common.CommonReportRequest;
import com.lzx.adx.report.model.sfkj.SfkjRequest;
import com.lzx.adx.report.model.youyou.YouYouRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@Slf4j
public class SfKjReportMappingStrategy  extends AbstractReportParamsMapping{
    @Override
    public CommonReportRequest adapter(Map<String, Object> params) {
        String jsonString = JSONObject.toJSONString(params);
        log.info("山风科技互联的原始参数为{}",jsonString);
        SfkjRequest sfkjRequest = JSONObject.parseObject(jsonString, SfkjRequest.class);
        CommonReportRequest commonReportRequest=new CommonReportRequest();
        BeanUtils.copyProperties(sfkjRequest,commonReportRequest);
        commonReportRequest.setEventType("click");
        commonReportRequest.setOs("android");
        commonReportRequest.setCallback(sfkjRequest.getCallbackUrl());
        return commonReportRequest;
    }
}
